package com.sky.blog.vo;


import com.sky.blog.dao.enums.ResponseCode;
import lombok.Data;

import java.io.Serializable;

/**
 * @author sky  2022/3/23
 * @version 1.0
 */
@Data
public class Results implements Serializable {
    /**
     * 公用的success返回集
     */
    public final static Results SUCCESS = new Results(ResponseCode.SUCCESS.getCode());

    /**
     * 状态码
     */
    private int code;

    /**
     * 返回消息
     */
    private String message;

    /**
     * 返回数据（json）
     */
    private Object data;

    public Results(int code) {
        this.code = code;
    }

    public Results(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static Results status(int code) {
        return new Results(code);
    }

    public Results message(String message) {
        this.message = message;
        return this;
    }

    public Results data(Object data) {
        this.data = data;
        return this;
    }

    @Override
    public String toString() {
        return "{\"code\":" + code + ", \"message\":" + message + ", \"data\":" + data + "}";
    }
}
